package it.prova.action;

import it.prova.Consts;
import it.prova.dialog.SingleNumericDialog;
import it.prova.dialog.SingleStringDialog;

import org.eclipse.jface.action.Action;
import org.w3c.dom.Element;

public class EntryUnitIterateAction extends Action
{
//	private Document currentModel;
	
	private Element element;
	
	public EntryUnitIterateAction()
	{
		setText("Valore");
	}
	
	/**
	 * @return Returns the element.
	 */
	public Element getElement()
	{
		return element;
	}

	/**
	 * @param element
	 *            The element to set.
	 */
	public void setElement(Element element)
	{
		this.element = element;
	}
	
	@Override
	public void run()
	{
		String value = element.getAttribute(Consts.TAG_ATTRIBUTE_VALUE);
		
		SingleStringDialog dialog = new SingleStringDialog
		(
			null, 
			"Numero di iterazioni", 
			value
		);
		
		int result = dialog.open();
		System.out.println("result = " + result);			
		String selectedAttributeValue = dialog.getSelectedAttributeValue();
		System.out.println("dialog.getSelectedAttributeValue() = " + selectedAttributeValue);
		
		element.setAttribute(Consts.TAG_ATTRIBUTE_VALUE, selectedAttributeValue);
	}
}